<template>
	<view class="receive">
		<view class="nav">
			<u-tabs :list="list1" lineColor="#FF5B1A" :activeStyle="{color: '#FF5B1A'}" @click="change" :scrollable="false"></u-tabs>
		</view>
		<scroll-view scroll-y="true" class="main" @scrolltolower="lower()">
			<view class="list" v-for="(item,index) of list" @click="detail(item.task.id)">
				<image :src="oss(item.postuser.avatar)" class="cover" mode=""></image>
				<view class="info">
					<view class="title">
						<view class="l">{{item.name}}</view>
					</view>
					<view class="types">
						<view class="btn">{{item.task.catename}}</view>
						<view class="btn btn1">{{item.task.platform}}</view>
					</view>
				</view>
				<view class="moeny">
					<view class="status" v-if="type === 0">进行中</view>
					<view class="status" v-if="type === 1">待审核</view>
					<view class="status" v-if="type === 2">已通过</view>
					<view class="status" v-if="type === -1" @click.stop="reason(item.note)">未通过.查看原因</view>
					<view class="num">佣金{{item.price}}元</view>
					<view class="btn"  v-if="type === 0" @click.stop="cancel(item.id)">取消</view>
				</view>
			</view>
			<u-empty v-if="list.length === 0 && finish" mode="data" marginTop="100">
			</u-empty>
		</scroll-view>
		<u-popup :show="show" @close="show = false" @open="show = true" mode="center" round="10">
			<view class="refuse">
				<textarea :value="note.content" disabled placeholder="拒绝理由" class="reason" />
				<image v-for="(item,index) in note.images" :src="oss(item)" class="example" mode="widthFix"></image>
			</view>
		</u-popup>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				list1: [{
					name: '进行中',
					type: 0,
				}, {
					name: '已取消',
					type: -2,
				}, {
					name: '待审核',
					type: 1
				}, {
					name: '已通过',
					type: 2
				}, {
					name: '未通过',
					type: -1
				}],
				show: false,
				page: 1,
				finish: false,
				type: 0,
				list: [],
				show3: false,
				note: '',
				id: '',
				pay_type:''
			}
		},
		onLoad(options) {
			this.id = options.id
			this.pay_type = options.type
			this.getList()
		},
		methods: {
			reason(note) {
				this.note = note[0]
				this.show = true
			},
			detail(id) {
				uni.$u.route({
					url: 'pages/task/detail',
					params: {
						id: id
					}
				})
			},
			cancel(id) {
				uni.$u.http.post('/taskorder', {
					id: id,
					types: 'cancel'
				}).then(res => {
					if (res.code == 1) {
						uni.$u.toast(res.msg)
						this.reload()
					}
				}).catch((res) => {
						
				})
			},
			tel(mobile) {
				uni.$u.http.post('/mobilelog',{
					mobile
				}).then(res => {
					if (res.code == 1) {
						uni.makePhoneCall({
							phoneNumber: mobile
						});
					}
				}).catch((res) => {
				
				})
			},
			toast(note) {
				this.note = note
				this.show3 = true
			},
			change(e) {
				console.log(e)
				this.type = e.type
				this.reload()
			},
			reload() {
				this.page = 1
				this.finish = false
				this.list = []
				this.getList()
			},
			lower() {
				this.page++
				this.getList()
			},
			getList() {
				if (this.finish) {
					return
				}
				uni.$u.http.post('/taskorder', {
					page: this.page,
					type: this.type,
					pay_type:this.pay_type
				}).then(res => {
					console.log(res)
					if (res.code == 1) {
						this.list = this.list.concat(res.data)
						if (res.data.length === 0) {
							this.finish = true
						}
					}
				}).catch((res) => {
		
				})
			}
		}
	}
</script>

<style lang="scss">
	.receive {
		height: 100vh;
		position: relative;
		background-color: #F6F6F6;
		.nav{
			display: flex;
			align-items: center;
			justify-content: center;
			flex-shrink: 0;
		}
		.refuse{
			padding: 40rpx;
			.reason{
				width: 400rpx;
				height: 180rpx;
				border-bottom: 1px solid #eee;
				margin-bottom: 20rpx;
			}
			.addBox{
				display: flex;
				align-items: center;
				justify-content: center;
				flex-direction: column;
				border: 1px solid #FFCE54;
				width: 130rpx;
				height: 130rpx;
				border-radius: 10rpx;
				.icon{
					width: 27rpx;
					height: 27rpx;
					margin-bottom: 10rpx;
				}
				.word{
					color: #FF8007;
					font-size: 22rpx;
				}
			}
			.example{
				width: 200rpx;
			}
			.btn{
				width: 200rpx;
				height: 60rpx;
				display: flex;
				align-items: center;
				justify-content: center;
				color: #fff;
				background: #FF5B1A;
				font-size: 28rpx;
				border-radius: 10rpx;
				margin: 20rpx auto 0;
			}
		}
		.main{
			position: absolute;
			left: 0;
			width: 100%;
			bottom: 0;
			top: 90rpx;
			padding-top: 20rpx;
			overflow: hidden;
		}
		.list{
			display: flex;
			margin: 0 20rpx 10rpx;
			padding: 20rpx;
			background-color: #fff;
			border-radius: 10rpx;
			align-items: center;
			position: relative;
			.vip{
				position: absolute;
				left: 0;
				top: 40rpx;
				width: 74rpx;
				height: 44rpx;
				.icon{
					width: 74rpx;
					height: 44rpx;
				}
				.word{
					width: 74rpx;
					height: 44rpx;
					display: flex;
					align-items: center;
					justify-content: center;
					color: #191615;
					font-size: 20rpx;
					position: absolute;
					left: 0;
					top: -10rpx;
					font-weight: bold;
				}
			}
			.cover{
				width: 140rpx;
				height: 140rpx;
				margin-right: 20rpx;
				flex-direction: 0;
				border-radius: 10rpx;
			}
			.address{
				font-size: 25rpx;
				color: #575859;
			}
			.moeny{
				
				margin-left: 40rpx;
				display: flex;
				flex-direction: column;
				align-items: center;
				.status{
					color: #428DFC;
					font-size: 30rpx;
					font-weight: bold;
				}
				.num{
					font-size: 24rpx;
					color: #FF5B1A;
					margin: 10rpx 0;
				}
				.btn{
					border: 1px solid #D5D5D5;
					width: 110rpx;
					height: 50rpx;
					box-sizing: border-box;
					color: #575859;
					display: flex;
					align-items: center;
					justify-content: center;
					border-radius: 25rpx;
					font-size: 24rpx;
				}
				.fail{
					color: #FF5B1A;
				}
			}
			.info{
				flex: 1;
				.title{
					display: flex;
					align-items: center;
					.l{
						flex: 1;
						overflow: hidden;
						white-space: nowrap;
						text-overflow: ellipsis;
						font-weight: bold;
					}
					.r{
						color: #428DFC;
						font-size: 24rpx;
						flex-shrink: 0;
						display: flex;
						align-items: center;
					}
				}
				.types{
					display: flex;
					align-items: center;
					margin: 20rpx 0;
					.btn{
						background: #FFFAE5;
						height: 36rpx;
						border-radius: 18rpx;
						padding: 0 10rpx;
						display: flex;
						align-items: center;
						justify-content: center;
						color: #FF8007;
						font-size: 24rpx;
						margin-right: 10rpx;
					}
					.btn1{
						background-color: #E9F3FF;
						color: #428DFC;
					}
				}
			}
		}
	}
</style>
